package io.xccit.order.controller;

import io.xccit.model.order.domain.Order;
import io.xccit.order.props.OrderNacosProperties;
import io.xccit.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author CH_ywx
 * @version 1.0
 * @create 2025/5/17
 * <p></p>
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private OrderNacosProperties orderNacosProperties;

    /**
     * 创建订单
     * @param userId
     * @param productId
     * @return
     */
    @GetMapping("/create")
    public Order createOrder(Long userId, Long productId) {
        return orderService.createOrder(userId, productId);
    }

    /**
     * 获取nacos配置
     * @return
     */
    @GetMapping("/nacos-config")
    public String getNacosConfig() {
        return orderNacosProperties.toString();
    }
}
